package test01;

import java.util.ArrayList;
import java.util.List;


public class ListTest {

    public static void main(String[] args) throws Exception {
        
        /*List<List<String>> list = new ArrayList<List<String>>();
        
        List<String> list1 = new ArrayList<String>();
        List<String> list2 = new ArrayList<String>();
        
        list1.add("111");
        list2.add("222");
        
        list.add(list1);
        list.add(list2);
        
        List<String> list3 = list.get(0);
        System.out.println(list3.get(0));
        change(list);
        System.out.println(list.get(0).get(0));
        A.aChange(list);
        System.out.println(list.get(0).get(0));
        new AClass().aChange(list);
        System.out.println(list.get(0).get(0));*/
        
        final AClass ac = new AClass();
        ac.setA("001");
        ac.setB(1);
        List<String> list = new ArrayList<String>();
        list.add("111111111");
        ac.setList(list);
        BClass bc = new BClass();
        
        bc.aCHandNull(ac);
        
        System.out.println(ac.getList());
        //AClass ac2 = (AClass) ac.clone();
        //final AClass ac2 = ac;
       /* AClass ac2 = new AClass();
        ac2.setA(ac.getA());
        ac2.setB(ac.getB());
        ac2.setList(ac.getList());
        new Thread(new Runnable() {
            @Override
            public void run() {
                bc.aCHand(ac2);
            }
        }).start();*/
       /* new Thread(new Runnable() {
            @Override
            public void run() {
                bc.aCHand(ac);
            }
        }).start();*/
        /*try {
            Thread.sleep(3000L);
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }*/
        /*System.out.println(ac.getA()+" && "+ac.getB()+" && "+ac.getList().get(0));//偶尔报exception
        for(int i=0;i<1000;i++){
            System.out.println(ac.getA()+" && "+ac.getB()+" && "+ac.getList());
        }*/
        
    }
    
    private static List<String> change(List<List<String>> list){
        List<List<String>> list2 =  new ArrayList<List<String>>();
        List<String> list3 =  new ArrayList<String>();
        list2.add(list3);
        list2.get(0).set(0, list.get(0).get(0));
        return list.get(0);    
    }
    
    /* BClass bc = new BClass();
    AClass ac = new AClass();
    ac.setA("aaa");
    bc.setAc(ac);
    
    ac.setA("bbb");
    ac=null;
    System.out.println(bc.getAc().getA());
    */
    // TODO Auto-generated method stub
    /*List<AClass> list = new ArrayList<AClass>();
    
    AClass a = new AClass();
    a.setA("1111");
    a.setB(111);
    list.add(a);
    a = null;
    System.out.println(list.get(0).getA());        //////////////第一次输出
    
    
    List<AClass> list2 = new ArrayList<AClass>();
    AClass a2 = new AClass();
    a2.setA("aaaa");
    list2.add(a2);
    a2.setA("bbbb");
    System.out.println(list2.get(0).getA());      ////////////第二次输出
*/

}

class A{
    public static List<String> aChange(List<List<String>> list){
            
            list.get(0).set(0, "333333333333333");
            
            return list.get(0);    
    }
}
